Ext.define('FirstMate.view.NWSForecast', {
	extend: 'Ext.Container',
	alias: 'widget.NWSforecastview',
	id : 'NWSForecastView',
	config : {
		layout : 'fit',
		items : [		         
		 {
		 docked: 'top',
		 xtype: 'toolbar',
		 layout : {
			 pack : 'center'
		 },
		 scrollable: {
			    direction: 'horizontal',
			    directionLock: true
		 },
		 //ui : 'light',
		 items : [
			        {
			        	id : 'zoneLabel',
			        	disabled : true,
			        	//text : 'Satellite',
				        //iconCls: 'globe2',
				        //iconMask: true,
				        ui : 'round'			
			        }
		          ]
		 },
		 {
			 id: 'NWSForecastPanel',
			 scrollable:true
		 }
		]
	},
	updateView : function (zone){
				
		Ext.Ajax.cors = true;
		Ext.Ajax.useDefaultXhrHeader = false;
		var maskMessage = '<span style="color:yellow">SAMPLE</span><br>Real Forecast for <br>' + 'the correct zone (above)'  + '<br>is available in the Pro version';		
		Ext.Ajax.request({
			method: "GET",
	        url : 'http://firstmaterouter.appspot.com/NWSZoneForecast',
	        params: {
	            "zone" : FirstMate.app.paidVersion ? zone[0] : 'PHZ122',
	            "APIKey" : FirstMate.app.fusionTablesAPIKey // fix this later
	        },
	        success : function(response, options) {
	        	Ext.getCmp('zoneLabel').setText(zone[1]);
	        	Ext.getCmp('NWSForecastPanel').setHtml(response.responseText);
	        	FirstMate.app.paidVersion ? null : 
	        			Ext.getCmp('NWSForecastPanel').setMasked({xtype:'loadmask', message: maskMessage});
	        },
	        failure : function(response, options) {
	            Ext.Msg.alert(response.responseText + " " + options.responseText);
	        }
	    });		
		
	}

});
